import {
	defineStore
} from 'pinia'
import {
	ref
} from 'vue'

// 定义 Store
export const useSettingStore = defineStore(
	'settings',
	() => {
		// 会员信息
		const settings = ref({})

		// 保存会员信息，登录时使用
		const setSetting = (val) => {
			settings.value = val

		}
		// 清理会员信息，退出时使用
		const clearSetting = () => {
			settings.value = undefined
		}



		// 记得 return
		return {
			settings,
			setSetting,
			clearSetting
		}
	}, {
		persist: {
			storage: {
				getItem(key) {
					return uni.getStorageSync(key)
				},
				setItem(key, value) {
					uni.setStorageSync(key, value)
				},
			},
		},
	},
)